Skip to content

Conversation

jserv
Copy link
Collaborator

@jserv jserv commented Aug 25, 2025

This recognizes the 16 most frequent C keywords inline before falling back to hashmap lookup. This fast-path covers the majority of keyword cases in typical C code and reduces lookup overhead.

  • "if" keyword (40% of occurrences): 3 operations vs 3-4 hashmap ops
  • "return" keyword (21% of occurrences): 3 operations vs 3-4 hashmap ops

Summary by Bito

This pull request introduces a fast-path inline keyword recognition feature for C, enhancing keyword lookup efficiency. It includes a new memory comparison function and improvements in lexer.c to directly recognize the 16 most frequent keywords, reducing hashmap reliance.

jserv added 2 commits August 25, 2025 18:54
This recognizes the 16 most frequent C keywords inline before falling
back to hashmap lookup. This fast-path covers the majority of keyword
cases in typical C code and reduces lookup overhead.
- "if" keyword (40% of occurrences): 3 operations vs 3-4 hashmap ops
- "return" keyword (21% of occurrences): 3 operations vs 3-4 hashmap ops
- Expected 5-10% overall lexer performance improvement
This introduces a simple byte-by-byte memory comparison function,
ensuring correctness and reliability in self-hosting environments.
@jserv jserv merged commit 6a97bd7 into master Aug 25, 2025
12 checks passed
@jserv jserv deleted the keyword-recognition branch August 25, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants